# -*- coding:utf-8 -*-
"""
@file: PandasIODemo01.py 
@time: 2019/07/16
@author: 
descript:https://www.pypandas.cn/user_guide/io/index.html
"""
base_path = "E:\\jupyter\\yxl\\exercises\\2019CCKSEL\\ccks2019_el"
base_path = r"E:\jupyter\yxl\exercises\2019CCKSEL\ccks2019_el\\"
# develop
develop_path = base_path + "develop.json"

# kb_data
kb_data_path = base_path + "kb_data.json"

# 快速复制 ctrl+D
train_path = base_path + "train.json"

import pandas as pd
import json
from tqdm import tqdm
import os
import numpy as np
import pymysql

develop_list = []
# f = open(develop_path,encoding="utf-8")
# for item in f.readlines():
# 	print(item)
# 	develop_list.append(json.loads(item.replace("\n","").strip()))
# f.close()
with open(develop_path,encoding="utf-8") as f:
	for item in tqdm(f):
		develop_list.append(json.loads(item.replace("\n","").strip()))

# develop_list
develop_liststr = json.dumps(develop_list, ensure_ascii=False, indent=4, default=lambda x: str(x))
print(develop_liststr)
# np.savetxt(base_path+"develop_list.json",develop_list)
with open(base_path+"develop_list.json","w",encoding="utf-8") as f:
	f.write(develop_liststr)
# data frame
df_develop = pd.read_json(base_path+"develop_list.json",encoding="utf-8")
df_develop = pd.DataFrame(develop_list)


print(df_develop)

